import Vue from 'vue';
import VueRouter from 'vue-router';
//将路由注入vue实列
Vue.use(VueRouter)
//定义路由匹配规则
const routes=[
    {
        path:'/',
        component:()=>import('@/Index'),
        //component:()=>import('@/components/Editor.vue'),
        children:[
            {
                path:'/mysql/2',
                name:'mysql2',
                component:()=>import('@/views/mysql')
                
            }
        ]
    },
    {
        path:'/javascript/:id',
        name:'javascript',
        component:()=>import('@/views/SharingJs'),
       props:(route)=>(
            {
                count:route.query.count,
                gh:route.query.gh,
                title:route.query.title,
                dates:route.query.dates,
                id:route.params.id
    
            }
            )//使用 props 将组件和路由解耦：不用props取参将使用this.$route.params.id进行取值
    },
   
    {
        path:'/java/:id',
        name:'java',
        component:()=>import('@/views/SharingJs'),
        props:(route)=>(
            {
                count:route.query.count,
                gh:route.query.gh,
                title:route.query.title,
                dates:route.query.dates,
                id:route.params.id
    
            }
            )
    },
    {
        path:'/Mysql/:id',
        name:'Mysql',
        component:()=>import('@/views/SharingJs'),
        props:(route)=>(
            {
                count:route.query.count,
                gh:route.query.gh,
                title:route.query.title,
                dates:route.query.dates,
                id:route.params.id
    
            }
            )
    },
    {
        path:'/Css/:id',
        name:'Css',
        component:()=>import('@/views/SharingJs'),
        props:(route)=>(
            {
                count:route.query.count,
                gh:route.query.gh,
                title:route.query.title,
                dates:route.query.dates,
                id:route.params.id
    
            }
            )
    },
    {
        path:'/VueRouter/:id',
        name:'VueRouter',
        component:()=>import('@/views/SharingJs'),
        props:(route)=>(
            {
                count:route.query.count,
                gh:route.query.gh,
                title:route.query.title,
                dates:route.query.dates,
                id:route.params.id
    
            }
            )
    },
    {
        path:'/Vuex/:id',
        name:'Vuex',
        component:()=>import('@/views/SharingJs'),
        props:(route)=>(
            {
                count:route.query.count,
                gh:route.query.gh,
                title:route.query.title,
                dates:route.query.dates,
                id:route.params.id
    
            }
            )
    },
    {
        path:'/Vue/:id',
        name:'Vue',
        component:()=>import('@/views/SharingJs'),
        props:(route)=>(
            {
                count:route.query.count,
                gh:route.query.gh,
                title:route.query.title,
                dates:route.query.dates,
                id:route.params.id
    
            }
            )
    },
    {
        path:'/Html/:id',
        name:'Html',
        component:()=>import('@/views/SharingJs'),
        props:(route)=>(
            {
                count:route.query.count,
                gh:route.query.gh,
                title:route.query.title,
                dates:route.query.dates,
                id:route.params.id
    
            }
            )
    },
    {
        path:'/SpringBoot/:id',
        name:'/SpringBoot/',
        component:()=>import('@/views/SharingJs'),
        props:(route)=>(
            {
                count:route.query.count,
                gh:route.query.gh,
                title:route.query.title,
                dates:route.query.dates,
                id:route.params.id
    
            }
            )
    }
    
]
//定义一个router实列
const router=new VueRouter({
    mode:'history',
    routes,
    scrollBehavior (to, from, savedPosition) {
       
        return { x:0, y: 0 }
      }
});

//将路由实列对象暴露出去
export default router;